﻿

using System;
using System.Text;
using System.Collections;
using System.Collections.Generic;
using Demo_G.O.S.E.ServerEngine.Util;
using Demo_G.O.S.E.ServerEngine.Common;


namespace Demo_G.O.S.E.ServerEngine.Mobile
{

	public enum Expansion
	{
		None,
		/*
		T2A,
		UOR,
		LBR,
		UOTD,
		*/
		AOS,
		SE,
		ML
	}

    public abstract class BaseRace
    {
        private static BaseRace[] m_Races = new BaseRace[0x100];

        public static BaseRace[] Races
        {
            get { return m_Races; }
        }

        private static ArrayList m_AllRaces = new ArrayList();

        public static ArrayList AllRaces
        {
            get { return m_AllRaces; }
        }

        private int m_RaceID, m_RaceIndex;

        private string m_Name, m_PluralName;

        private static string[] m_RaceNames;
        private static BaseRace[] m_RaceValues;

        public static string[] GetRaceNames()
        {
            CheckNamesAndValues();
            return m_RaceNames;
        }

        public static BaseRace[] GetRaceValues()
        {
            CheckNamesAndValues();
            return m_RaceValues;
        }

        public static BaseRace Parse( string value )
        {
            CheckNamesAndValues();

            for ( int i = 0; i < m_RaceNames.Length; ++i )
            {
                if ( Insensitive.Equals( m_RaceNames[i], value ) )
                    return m_RaceValues[i];
            }

            int index;
            if ( int.TryParse( value, out index ) )
            {
                if ( index >= 0 && index < m_Races.Length && m_Races[index] != null )
                    return m_Races[index];
            }

            throw new Exception( "Invalid race name" );
        }

        private static void CheckNamesAndValues()
        {
            if ( m_RaceNames != null && m_RaceNames.Length == m_AllRaces.Count )
                return;

            m_RaceNames = new string[m_AllRaces.Count];
            m_RaceValues = new BaseRace[m_AllRaces.Count];

            for ( int i = 0; i < m_AllRaces.Count; ++i )
            {
                BaseRace race = (BaseRace)m_AllRaces[i];

                m_RaceNames[i] = race.Name;
                m_RaceValues[i] = race;
            }
        }

        public override string ToString()
        {
            return m_Name;
        }

        private int m_MaleBody, m_FemaleBody, m_MaleGhostBody, m_FemaleGhostBody;

        private Expansion m_RequiredExpansion;

        public Expansion RequiredExpansion { get { return m_RequiredExpansion; } }

        public BaseRace( int raceID, int raceIndex, string name, string pluralName, int maleBody, int femaleBody, int maleGhostBody, int femaleGhostBody, Expansion requiredExpansion )
        {
            m_RaceID = raceID;
            m_RaceIndex = raceIndex;

            m_Name = name;

            m_MaleBody = maleBody;
            m_FemaleBody = femaleBody;
            m_MaleGhostBody = maleGhostBody;
            m_FemaleGhostBody = femaleGhostBody;

            m_RequiredExpansion = requiredExpansion;
            m_PluralName = pluralName;
        }

        //public virtual bool ValidateHair( BaseMobile m, int itemID ) { return ValidateHair( m.Female, itemID ); }
        public abstract bool ValidateHair( bool female, int itemID );

        //public virtual int RandomHair( BaseMobile m ) { return RandomHair( m.Female ); }
        public abstract int RandomHair( bool female );

        //public virtual bool ValidateFacialHair( BaseMobile m, int itemID ) { return ValidateFacialHair( m.Female, itemID ); }
        public abstract bool ValidateFacialHair( bool female, int itemID );

        //public virtual int RandomFacialHair( BaseMobile m ) { return RandomFacialHair( m.Female ); }
        public abstract int RandomFacialHair( bool female );	//For the *ahem* bearded ladies

        public abstract int ClipSkinHue( int hue );
        public abstract int RandomSkinHue();

        public abstract int ClipHairHue( int hue );
        public abstract int RandomHairHue();

        public int RaceID
        {
            get { return m_RaceID; }
        }

        public int RaceIndex
        {
            get { return m_RaceIndex; }
        }

        public string Name
        {
            get { return m_Name; }
            set { m_Name = value; }
        }

        public string PluralName
        {
            get { return m_PluralName; }
            set { m_PluralName = value; }
        }
    }
}

